<link rel="stylesheet" href="/public/boots/css/message.css">
<div id="message">
    <h3>在线留言 <span>当前未读信息 {{ $messageNum }} 条!</span></h3>
    <form method="post" action="{{ route('message_do') }}">
        {!! csrf_field() !!}
        <input type="text" name="msg_name" placeholder="请填写您的姓名">
        <input type="text" name="phone" placeholder="请填写您的联系电话">
        <input type="text" name="email" placeholder="请填写你的联系邮箱">
        <textarea name="message" placeholder="请填写您的留言内容"></textarea>
        <button>提交留言</button>
    </form>
</div>
<!--提示美化 Js引入-->
<link rel="stylesheet" href="/public/boots/js/alert/BeAlert.css">
<script src="/public/boots/js/alert/BeAlert.js"></script>
<script>
    $('#message h3').click(function () {
        $(this).siblings('form').slideToggle(500);
    })

    //得到错误提示
    var errorinfo = '';
    @if (count($errors) > 0)
            @foreach ($errors->all() as $error)
        errorinfo += '{{ $error }}<br>';
    @endforeach
            @endif


    if (errorinfo.length > 0) {
        $(function () {
            alert('操作失败', errorinfo, function () {
                //after click the confirm button, will run this callback function
            }, {type: 'warning', confirmButtonText: '好的'});
        })
    }

    //得到信息
    @if (!empty(session()->get('message')))
    $(function () {
        alert("{{ session()->get('message')['msg'] }}", '{{ session()->get('message')['explain'] }}', function () {
            //after click the confirm button, will run this callback function
        }, {type: '{{ session()->get('message')['status']?'success':'warning' }}', confirmButtonText: '好的'});
    })
    @endif
</script>
